<?php Yii::app()->clientScript->registerScriptFile(Yii::app()->url->theme.'script/slider.js'); ?>

<?php
if(!isset($model) || !$model) $model=new SliderBanner();
$languages=Language::model()->all;
?>

<div class="grid_12">
    <div id="slider-popup" class="module">
        <h2>
            <div class="popup-head">
                <span><?php echo $model->id ? Yii::t('slider','slide').' "'.$model->name.'"' : Yii::t('slider','newSlide'); ?></span>
                <?php echo CHtml::link('','#',array(
                    'class'=>'close-link',
                    'onClick'=>'Main.closePopup($("#slider-popup")); return false;',
                )); ?>
            </div>
        </h2>

        <div class="module-body">

            <?php $form=$this->beginWidget('CActiveForm', array(
                'id'=>'slider-form',
                'action'=>Yii::app()->createUrl('slider/index/save'),
                'method'=>'post',
                'enableAjaxValidation'=>true,
                'clientOptions'=>array(
                    'validateOnSubmit'=>true,
                    'validateOnChange'=>false,
                ),
                'htmlOptions'=>array(
                    'enctype'=>'multipart/form-data',
                ),
            )); ?>

            <?php echo CHtml::errorSummary(array($model)); ?>

            <?php echo $form->hiddenField($model,'id'); ?>
            <?php //echo CHtml::hiddenField(Yii::app()->request->csrfTokenName,Yii::app()->request->csrfToken); ?>

            <?php echo $form->label($model,'name',array('class'=>'main-label')); ?>

            <?php $this->widget('MultiLangFields',array('settings'=>array(
                'model'=>$model,
                'name'=>'slideName',
                'divClass'=>'formline',
                'inputClass'=>'input-short',
            ))); ?>

            <?php echo $form->label($model,'image',array('class'=>'main-label')); ?>

            <div class="formline">
                <?php echo $form->label($model,'image'); ?>

                <div class="input-short-img input-short">
                    <label class="input-short-img"><?php echo $model->picture; ?></label>

                    <?php echo $form->fileField($model,'imageName',array(
                        'class'=>'input-short',
                    )); ?>
                </div>
            </div>

            <div class="formline">
                <?php echo $form->label($model,'imageLink'); ?>

                <?php echo $form->textField($model,'imageLink',array(
                    'placeholder'=>$model->getAttributeLabel('imageLink'),
                    'class'=>'input-short',
                )); ?>
            </div>

            <?php echo $form->label($model,'infoText',array('class'=>'main-label')); ?>

            <?php $this->widget('MultiLangFields',array('settings'=>array(
                'model'=>$model,
                'name'=>'infoText',
                'divClass'=>'formline',
                'inputClass'=>'input-short'
            ))); ?>

            <div class="formline">
                <?php echo $form->label($model,'infoTextLink'); ?>

                <?php echo $form->textField($model,'infoTextLink',array(
                    'placeholder'=>$model->getAttributeLabel('infoTextLink'),
                    'class'=>'input-short',
                )) ?>
            </div>

            <?php echo $form->label($model,'infoTextLinkTitle',array('class'=>'main-label')); ?>

            <?php $this->widget('MultiLangFields',array('settings'=>array(
                'model'=>$model,
                'name'=>'infoTextLinkTitle',
                'divClass'=>'formline',
                'inputClass'=>'input-short'
            ))); ?>

            <label class="main-label"><?php echo Yii::t('main','other') ?></label>

            <div class="formline">
                <?php echo $form->label($model,'sort'); ?>

                <?php echo $form->textField($model,'sort',array(
                    'placeholder'=>$model->getAttributeLabel('sort'),
                    'class'=>'input-short',
                )) ?>
            </div>

            <div class="formline">
                <?php echo $form->label($model,'isActive'); ?>

                <?php echo $form->checkBox($model,'isActive',array(
                    'class'=>'left',
                )) ?>
            </div>

            <fieldset>

                <?php echo CHtml::submitButton(Yii::t('main','save'),array(
                    'class'=>'submit-green left',
                )); ?>

                <?php echo CHtml::link(Yii::t('main','remove'), Yii::app()->createUrl('slider/index/delete', array('id'=>$model->id)),array(
                    'class'=>'submit-green left',
                    'onClick'=>'return confirm("'.Yii::t('slider','confirmDelete',array('{slide}'=>$model->name)).'");'
                )); ?>

            </fieldset>

            <?php $this->endWidget(); ?>

        </div> <!-- module-body -->

    </div> <!-- module -->
</div> <!-- grid_12 -->
